<script setup>
// 路由
import { createRouter } from 'vue-router'

const veg = {
    id: 1,
    name: "小龙虾",
    photo: "https://images.pexels.com/photos/4353638/pexels-photo-4353638.jpeg?auto=compress&cs=tinysrgb&w=1600",
    price: 15,
    info: "小龙虾很好吃",
    type: "海鲜"
}


const buy = () => {
    alert("购买成功")
}

const back = () => {
    window.history.back()
}
</script>

<template>
    <div class="back" @click="back">返回</div>
    <div class="intro">
        <img class="introImg" :src="veg.photo" alt="  ">
        <div class="introPrice">{{ veg.price }}</div>
        <div class="introName">{{ veg.name }}</div>
        <div class="introInfo">{{ veg.info }}</div>
        <button class="introBtn" @click="buy(veg)">加入购物车</button>
    </div>
</template>

<style scoped>
.back {
    height: 40px;
    width: 40px;
    background-color: gray;
    border-radius: 40px;
    line-height: 40px;
    text-align: center;
}

.intro {
    display: flex;
    flex-flow: column nowrap;
}

.introImg {
    background-color: antiquewhite;
    height: 400px;

}

.introPrice {
    color: red;
    font-size: 20px;
    margin-top: 5px;

}

.introName {
    font-size: 20px;
    margin-top: 5px;
}

.introInfo {
    font-size: 15px;
    margin-top: 5px;
}

.introBtn {
    height: 40px;
    margin-top: 10px;
    background-color: skyblue;
    color: white;
    border: none;
    border-radius: 20px;
}
</style>